<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/js/themes/default/easyui.css" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/js/themes/icon.css" />
 	<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-1.4.4.min.js"></script>
 	<script type="text/javascript" src="${pageContext.request.contextPath}/My97DatePicker/WdatePicker.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/homepages/js/functions.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.easyui.min.1.2.2.js"></script>
    
	<script type="text/javascript">
		var a = document.documentElement.clientHeight - 72;
		var b = document.documentElement.clientWidth - 25;
		$(function(){
			loadPages();
			var lastIndex;
			//填充相应的录单界面
			$('#DATALIST').datagrid({
				iconCls:'icon-save',
				nowrap: false,
				width:b,
				height:a,
				striped: true,				 
				collapsible:true,
				autoRowHeight: false,		
				remoteSort: false,
				fitColumns:true,
				singleSelect:true,
				columns:[[]],
				pagination:true,
				rownumbers:true,
				onDblClickRow:function(rowIndex){
					alert(rowIndex);
					if (lastIndex != rowIndex){
						$('#DATALIST').datagrid('endEdit', lastIndex);
						$('#DATALIST').datagrid('beginEdit', rowIndex);
					}
					lastIndex = rowIndex;
				},
				onAfterEdit:function(rowIndex,rowData,changes){
					//完成后将修改后的值传入后台修改				 
				}
			});
		});
		
		function resizeGrid(){
			var a = document.documentElement.clientHeight - 72;
			var b = document.documentElement.clientWidth - 25;
			$('#DATALIST').datagrid('resize', {
				width:b,
				height:a
 	  		 });
		}
		function loadPages(){
			$('#DATALIST').load('${pageContext.request.contextPath}/pageConfig/pagesUrl',
				{'configId':'XTConfig','funcsId':''});
		}
		
		function saveTopic(){
			var verify=$('input[name = isVerify]').val();
			if(verify == 'on'){
				$('input[name = isVerify]').val('T');
			}else{
				$('input[name = isVerify]').val('F')
			}
			$.ajax({
				type:'post',
				url:'${pageContext.request.contextPath}/bjTopic/saveTopic',
				data:$('#INFO_FORM').serialize(),
				success:function(data){
					if(data == 1){
						alert("添加成功");
						$('#applyTopic').close();
						loadPages();
					}else{
						alert("添加失败"); 
					}
				}
			})
		}
		
 
		function saveXT(){
			$('#applyTopic').show();
			$('#applyTopic').dialog({
				width:'1200',
				collapsible: true,
				minimizable: true,
				maximizable: true,
				title:'添加选题'
			});
			$('#applyTopic').load('${pageContext.request.contextPath}/butScript/singleInput',
				{'configId':'SaveTopic'});
		}
		function findOtherButn(){
			var formId= $('#formId').val();
			$.ajax({
				 type:'post',
				 url:'${pageContext.request.contextPath}/topic/specialButn',
				 data:{'formType':formId,'name':'applyTopics'},
				 success:function(da){
				 	//拼接到保存按钮后面
				 	var butns= $('#butn');
				 	for(var i=0;i<da.length;i++){
				 		butns.append("<input type='button' value="+da[i].butnName+" onclick="+"'"+da[i].scriptFunc+"'"+"/>");
				 	}
				 }
			})
		}
		 
		function applyTopic(){
			var dsId = $('#dsId').val();
			$.ajax({
				type:'post',
				url:'${pageContext.request.contextPath}/topic/approvesTopic',
				data:{'dsId':dsId},
				success:function(data){
					alert("OK"+data.length);
					var str="<div style='border: 1px solid; width: 800px;'>";
					$('#applyTopic').show();
					$('#applyTopic').dialog({
						width:'900',
						collapsible: true,
						minimizable: true,
						maximizable: true
					});
					//把列加载到div
					str+="<table><tr><td>审批名称</td><td><input type='text' /></td><td>上级审批</td>"+
							"<td><select><option>是</option>	<option>否</option></select>	</td><td>允许审批</td><td><select>"+
							"<option>是</option>	<option>否</option></select></td></tr><tr><td>审批意见</td><td colspan='5'>"+
							"<textarea rows='2' cols='70'></textarea><input type='button' value='...'/></td></tr>"+
							"<tr><td>状态</td><td><input type='text' value='已通过'/></td><td>审批日期</td><td><input type='text'/></td>"+
							"<td>审批人</td><td><input type='text'/></td></tr></table>"
					str+="</div>";
					var str1="<table><tr><td><input type='button' value='保存' onclick='saveApply()'/></td></tr></table>";
					for(var i=0;i<data.length;i++){
						$('#applyTopic').append(str);
					}
					$('#applyTopic').append(str1);
				}
				
			})
		}
		function saveApply(){
			alert("保存");
			//$.ajax({
				//type:'post',
				//url:'',
				//data:'',
				//success:function(){
					//alert("OK");
				//}
			//})
		}
	</script>
</head>
<body  onresize="resizeGrid();">
	<form action="" method="post" id="queryForm">
		<table cellpadding="0" cellspacing="0">
			<tr>
				<td>
					<!-- 部分查询框 -->
					<table id="COLUMNS">
					</table>
				</td>
				<td style="vertical-align: top;">
					<!-- 部分按钮 -->
					<div id="BUTTONS" style="width:195px;padding-left: 20px;"></div>
				</td>
			</tr>
			<tr>
				<td colspan="2">
					<!-- 数据列表 -->	
					<table  id="DATALIST"></table>
				</td>
			</tr>
		</table>
	</form>
	<div id="applyTopic" style="display: none;"></div>  <!-- 添加按钮点击弹出添加界面 -->
	<input type="hidden" id="configId" value="${configId}"/>
	<input type="hidden" id="funcsId" value="${funcsId}"/>
</body>
</html>